package org.jeecg.modules.xxgx.kpzdgl.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.common.util.LoginUserUtil;
import org.jeecg.modules.xxgx.common.enums.KpzdztEnum;
import org.jeecg.modules.xxgx.kpzdgl.entity.CsXxKpzd;
import org.jeecg.modules.xxgx.kpzdgl.entity.CsXxKpzdSmplParam;
import org.jeecg.modules.xxgx.kpzdgl.service.ICsXxKpzdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;

/**
* @Description: 开票终端扩展
* @Author: jeecg-boot
* @Date:   2023-08-19
* @Version: V1.0
*/
@Api(tags="开票终端")
@RestController
@RequestMapping("/xxgx/kpzdgl/csXxKpzdkz")
@Slf4j
public class CsXxKpzdkzController extends JeecgController<CsXxKpzd, ICsXxKpzdService> {
   @Autowired
   private ICsXxKpzdService csXxKpzdService;


    @AutoLog(value = "扫码认证-认证刷脸频率设置")
    @ApiOperation(value="扫码认证-认证刷脸频率设置", notes="扫码认证-认证刷脸频率设置")
    @RequestMapping(value = "/editSmpl", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> editSmpl(@RequestBody CsXxKpzdSmplParam param) {
        CsXxKpzd csXxKpzd =  csXxKpzdService.getById(param.getId());
        csXxKpzd.setSmpl(param.getSmpl());
        csXxKpzdService.updateById(csXxKpzd);
        return Result.OK("设置成功!");
    }

    @AutoLog(value = "扫码认证-认证成功操作")
    @ApiOperation(value="扫码认证-认证成功操作", notes="扫码认证-认证成功操作")
    @RequestMapping(value = "/rzcg", method = {RequestMethod.PUT,RequestMethod.POST})
    public Result<String> rzcg(@ApiParam(value = "开票终端ID", required = true)
                               @RequestParam(name = "id", required = true) String id) {
        CsXxKpzd csXxKpzd =  csXxKpzdService.getById(id);
        csXxKpzd.setId(id);
        csXxKpzd.setRzjg(KpzdztEnum.yrz.getValue());
        csXxKpzd.setZjsmsj(new Date());
        csXxKpzd.setXcrzsj(csXxKpzd.getXcrzsj());
        csXxKpzdService.updateById(csXxKpzd);
        return Result.OK("操作成功!");
    }
    /**
     * 切换默认终端
     *
     * @param req
     * @return
     */
    @ApiOperation(value="切换默认终端", notes="切换默认终端")
    @GetMapping(value = "/changeMrzd")
    public Result<String> changeMrzd(@RequestParam(name="companyId",required = true) String companyId,
                                     @RequestParam(name="zdlx",required = true) String zdlx,
                                     @RequestParam(name="zddm",required = true) String zddm,
                                     HttpServletRequest req) {
        return csXxKpzdService.changeMrzd(companyId,zdlx,zddm);
    }
}
